<?php

namespace app\admin\model\outhouse;

use think\Model;
use traits\model\SoftDelete;

class CheckVouchList extends Model
{

    //use SoftDelete;  //开启后软删，同时列表不显示
    // 表名
    protected $name = 'check_vouch_list';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'datetime';

    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';
    
    protected $type = [
        'iQuantity' => 'quantity',
        'iAdInQuantity' => 'quantity',
        'iAdOutQuantity' => 'quantity',
        'iCVCQuantity' => 'quantity',
        'kc_qty' => 'quantity',
        'check_qty' => 'quantity',
        'kc_quantity' => 'quantity',
        'duringIn' => 'quantity',
        'duringOut' => 'quantity',
        'check_auxqty' => 'quantity',
        'check_qty' => 'quantity'
    ];
    
    // 追加属性
    protected $append = [
        'scan_flag_text'
    ];
    
    /* public function getScanTypeList()
    {
        return ['1' => __('Scanflag 0'), '2' => __('Scanflag 1')];
    } */
    public function getScanFlagTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['scan_flag']) ? $data['scan_flag'] : 0);
        //$list = $this->getTypeList();
        return $value==1?'已扫描':'待扫描';
    }

    public function vouch()
    {
        return $this->hasOne('\app\admin\model\outhouse\CheckVouch', 'code', 'code');
    }
    public function shelves(){
        return $this->hasOne('\app\common\model\Shelves','id','shelves_id')->field('id,name');
    }

}
